﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        private IdleMonitor idleMonitor;

        public Form1()
        {
            InitializeComponent();

            idleMonitor = new IdleMonitor(10);
            idleMonitor.IdleTick += IdleMonitor_IdleTick;
            idleMonitor.IdleElapsed += IdleMonitor_IdleElapsed;
            idleMonitor.Start();
        }

        private void IdleMonitor_IdleTick(object sender, int seconds)
        {
            label1.Text = $"{DateTime.Now:HH:mm:ss}  已经闲置 {seconds} 秒 (阈值 {idleMonitor.IdleThreshold})";
        }

        private void IdleMonitor_IdleElapsed(object sender, EventArgs e)
        {
            // 在这里做关屏、锁屏、提示等操作
            MessageBox.Show("已达到闲置阈值！");
        }

    } 
}
